@echo off
  set dst=_upload

  set D=%DATE%
  rem DD.MM.YYYY -> YYYY.MM.DD
  if "%D:~2,1%" == "." if "%D:~5,1%" == "." set D=%D:~6,4%.%D:~3,2%.%D:~0,2%

  call :pack gnu
  call :pack uname
  call :pack printf
goto :EOF

:pack
  call :pack_file %1 32 _Release\%1.exe
  call :pack_file %1 64 _Release\win64\%1.exe
goto :EOF

:pack_file
  set arch=%dst%\%1-%2-%D%.7z
  if exist %arch% call :run del /q %arch%

  call :run copy /y %3 %1.exe
  call :run 7z a -mx=9 -mmt=%NUMBER_OF_PROCESSORS% %arch% %1.exe
  call :run del /q %1.exe
goto :EOF

:run
  echo %*
  %* 1>NUL
goto :EOF
